/*
. * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.hera.process.config.domain;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import com.hera.base.domain.BaseDomain;

/**
 *
 * @author cmontes
 */
@Entity
@Table(name = "BUSINESS_DAY")
public class BusinessDay extends BaseDomain implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected BusinessDayPK businessDayPK;
    @JoinColumn(name = "ID_CALENDAR", referencedColumnName = "ID_CALENDAR", insertable = false, updatable = false)
    @ManyToOne
    private Calendar calendar;

    @JoinColumn(name = "ID_BUSINESS_DAY", referencedColumnName = "ID_PARAMETER_DETAIL", insertable = false, updatable = false)
    @ManyToOne
    private ParameterDetail day ;
    //@OneToMany(cascade = CascadeType.ALL, mappedBy = "businessDay")
    @Transient
    private List<BusinessHour> businessHourList;

    public BusinessDay() {
    }

    public BusinessDay(BusinessDayPK businessDayPK) {
        this.businessDayPK = businessDayPK;
    }

    public BusinessDay(Long idCalendar, Long idBusinessDay) {
        this.businessDayPK = new BusinessDayPK(idCalendar, idBusinessDay);
    }

    public BusinessDayPK getBusinessDayPK() {
        return businessDayPK;
    }

    public void setBusinessDayPK(BusinessDayPK businessDayPK) {
        this.businessDayPK = businessDayPK;
    }

    public Calendar getCalendar() {
        return calendar;
    }

    public void setCalendar(Calendar calendar) {
        this.calendar = calendar;
    }

    public List<BusinessHour> getBusinessHourList() {
        return businessHourList;
    }

    public void setBusinessHourList(List<BusinessHour> businessHourList) {
        this.businessHourList = businessHourList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (businessDayPK != null ? businessDayPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        
        if (!(object instanceof BusinessDay)) {
            return false;
        }
        BusinessDay other = (BusinessDay) object;
        if ((this.businessDayPK == null && other.businessDayPK != null) || (this.businessDayPK != null && !this.businessDayPK.equals(other.businessDayPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.hera.process.data.domain2.BusinessDay[ businessDayPK=" + businessDayPK + " ]";
    }

	public ParameterDetail getDay() {
		return day;
	}

	public void setDay(ParameterDetail day) {
		this.day = day;
	}
    
}
